package com.cssy.xxkj.logic.dao.impl;

import java.util.List;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.cssy.xxkj.logic.dao.LogicProductionDispatchDAO;
import com.cssy.xxkj.logic.entity.LogicProductionDispatchDO;
import com.plat.helper.SearchConditions;

/**
 * 数据访问对象实现类
 * @since 2014-09-28
 */
public class LogicProductionDispatchDAOImpl extends SqlMapClientDaoSupport implements LogicProductionDispatchDAO {

    /**
     * 插入数据
     * @param logicProductionDispatchDO
     * @return 插入数据的主键
     */
    public String insertLogicProductionDispatchDO(LogicProductionDispatchDO logicProductionDispatchDO) {
        Object id = getSqlMapClientTemplate().insert("LogicProductionDispatch.insert", logicProductionDispatchDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param logicProductionDispatchDO
     * @return 查出的记录数
     */
    public Integer countLogicProductionDispatchDOByExample(LogicProductionDispatchDO logicProductionDispatchDO) {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicProductionDispatch.countByDOExample", logicProductionDispatchDO);
        return count;
    }

    /**
     * 更新记录
     * @param logicProductionDispatchDO
     * @return 受影响的行数
     */
    public Integer updateLogicProductionDispatchDO(LogicProductionDispatchDO logicProductionDispatchDO) {
        int result = getSqlMapClientTemplate().update("LogicProductionDispatch.update", logicProductionDispatchDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param logicProductionDispatchDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<LogicProductionDispatchDO> findListByExample(LogicProductionDispatchDO logicProductionDispatchDO) {
        List<LogicProductionDispatchDO> list = getSqlMapClientTemplate().queryForList("LogicProductionDispatch.findListByDO", logicProductionDispatchDO);
        return list;
    }

    /**
     * 根据主键获取logicProductionDispatchDO
     * @param id
     * @return logicProductionDispatchDO
     */
    public LogicProductionDispatchDO findLogicProductionDispatchDOByPrimaryKey(String id) {
        LogicProductionDispatchDO logicProductionDispatchDO = (LogicProductionDispatchDO) getSqlMapClientTemplate().queryForObject("LogicProductionDispatch.findByPrimaryKey", id);
        return logicProductionDispatchDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteLogicProductionDispatchDOByPrimaryKey(String id) {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicProductionDispatch.deleteByPrimaryKey", id);
        return rows;
    }

	@Override
	public List<LogicProductionDispatchDO> find(SearchConditions scs)
			throws DataAccessException {
		List<LogicProductionDispatchDO> list = getSqlMapClientTemplate().queryForList("LogicProductionDispatch_ex.find", scs);
        return list;
	}

	@Override
	public Integer count(SearchConditions scs) throws DataAccessException {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicProductionDispatch_ex.count", scs);
        return count;
	}

	@Override
	public Integer deleteBizRemoved(String id) throws DataAccessException {
		Integer count = (Integer) getSqlMapClientTemplate().delete("LogicProductionDispatch_ex.deleteBizRemoved", id);
        return count;
	}

}